package com.cms.admin.service.usercard.impl;

import com.cms.admin.mapper.UserCardTypeMapper;
import com.cms.admin.model.PageBean;
import com.cms.admin.model.UserCardType;
import com.cms.admin.model.UserCardTypeExt;
import com.cms.admin.service.usercard.UserCardService;

import java.util.List;

/**
 * Created by YYY-Work on 2017/5/12.
 */
public class UserCardServiceImpl implements UserCardService{

    private UserCardTypeMapper userCardTypeMapper;
    @Override
    public List<UserCardType> selectUserCardType(PageBean page, UserCardTypeExt example) {

        long count = getRowCount(example);
        page.setAllRow(count);
        example.setOffset(page.getOffset());
        example.setPageSize(page.getPageSize());
        return userCardTypeMapper.selectByConditionWithLimit(example);
    }

    @Override
    public long getRowCount(UserCardTypeExt example) {
        return userCardTypeMapper.countByCondition(example);
    }

    @Override
    public int addUserCardType(UserCardTypeExt record) {
        return userCardTypeMapper.insertSelective(record);
    }

    @Override
    public int updateUserCardType(UserCardTypeExt record) {
        return userCardTypeMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public UserCardType selectUserCardTypeByCardId(Long cardtypeid) {
        return userCardTypeMapper.selectByCardTYPEid(cardtypeid);
    }

    public UserCardTypeMapper getUserCardTypeMapper() {
        return userCardTypeMapper;
    }

    public void setUserCardTypeMapper(UserCardTypeMapper userCardTypeMapper) {
        this.userCardTypeMapper = userCardTypeMapper;
    }
}
